package org.ling.xuan.entity.mo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.ling.xuan.util.EmailUtil;

import java.util.Date;

@Data
public class EmailSetting {
    private String host = "";
    private int port = 8080;
    private String email = "";
    private String password = "";
    private boolean ssl = false;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date ctdTime;
    private String type;

    public boolean checkConnect() {
        try {
            EmailUtil.getSession(host, String.valueOf(port), ssl, email, password);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}
